package com.lj.utils.result;

import com.lj.utils.exception.APIException;
import lombok.Data;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.ToString;

/**
 * 统一结果返回 请参照 ResponseControllerAdvice
 *
 * @param <T>
 */
@Data
@NoArgsConstructor
public class ResultVO<T> {
    //状态码
    private int code;
    //响应信息，用来说明响应情况
    private String msg;

    //响应的具体数据
    private T data;

    public ResultVO(T data) {
        this(ResultCode.SUCCESS, data);
    }

    public ResultVO(ResultCode resultCode, T data) {
        this.code = resultCode.getCode();
        this.msg = resultCode.getMsg();
        this.data = data;
    }

    public ResultVO(int code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }
}
